package com.atguigu.controller;

import com.atguigu.commonutils.R;
import com.atguigu.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther: fangshicai
 * @Date: 2022/1/23 22:42
 * @Description:
 */

@RestController
@CrossOrigin
@RequestMapping("/oss/file")
@Api(description="阿里云文件管理")
public class OssController {

    @Autowired
    private FileService fileService;

    /**
     * 文件上传
     * MultipartFile选择文件上传
    **/

    @PostMapping("upload")
    public R upload(
                    @ApiParam(name = "file", value = "文件", required = true)
                    @RequestParam("file") MultipartFile file){
        String url= fileService.fileUpload(file);
        return R.ok().data("url",url);
    }

}
